home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
-
- # Set some variables which would be difficult to do within a makefile, e.g.
- # the date
-
- PATH=/bin
-
- RXDAY=`date +%d`
- RXMONTH=`date +%m`
- RXYEAR=`date +%y`
-
- RXDAY=`expr $RXDAY + 0`
- RXMONTH=`expr $RXMONTH + 0`
- RXYEAR=`expr $RXYEAR + 0`
-
- GNUDIR=`echo /usr/local/lib/gnu/gcc/sun?/2.*` # Yuck...
-
- CCFLAG=""
- LDFLAG=""
- DEBUG=""
-
- if [ ! -d ${BINDIR:=${HOME}/`/bin/arch`} ]; then BINDIR=`pwd`; fi
-
- echo ${REXXIMC:=$BINDIR} >/dev/null # default directory to find rxque/rxmathfn
-
- # The first parameter may be a single letter, indicating the type of
- # compilation required: n (no flags) g (debug) d (really debug)
- # a or p (profile) o (optimise). The default is optimise.
- # By default, all compilations except -a are done by gcc.
-
- CC=/usr/local/bin/gcc # change to cc if desired
- LDL=-ldl
-
- case ${1:-nothing} in
- g) CCFLAG=-g;shift;;
- a) CCFLAG=-a;CC=cc;shift;;
- p) CCFLAG="-p -DNO_LDL";LDL="";shift;;
- pg) CCFLAG="-pg -DNO_LDL";LDL="";shift;;
- d) CCFLAG="-g -DDEBUG";
- DEBUG="/usr/lib/debug/malloc.o /usr/lib/debug/mallocmap.o";shift;;
- o) CCFLAG=-O2;LDFLAG="-s -n -Bdynamic";shift;;
- n) ;;
- *) CCFLAG=-O2;LDFLAG="-s -n -Bdynamic";;
- esac
-
- export PATH CCFLAG LDFLAG DEBUG RXDAY RXMONTH RXYEAR BINDIR REXXIMC CC LDL
-
- # Move object files and, if "install", executables, from bin directory
- # into current directory. This does not happen for "clean" or "lint"
- # but it does happen for "clobber"
-
- savedir=`pwd`
- if [ x$1 != xclean -a x$1 != xlint ]; then
- mvfiles="*.o rxmathfn.rxfn"
- if [ x$1 = xinstall ] ; then
- mvfiles="$mvfiles rexx rxque rxstack";
- fi
- (cd $BINDIR;mv $mvfiles $savedir >/dev/null 2>&1);
- fi
-
- # The following setup depends on whether cc or /usr/local/bin/gcc was chosen.
-
- if [ $CC = cc ] ; then
- LD=cc
- __MAIN=
- else
- LD=cc
- __MAIN="-L$GNUDIR -lgcc"
- fi
-
- export LD __MAIN
-
- echo '
- #Makefile for REXX/imc
- #Following setup is for SunOS 4.1.1
- MORECCFLAGS = -DHAS_TTYCOM -DHAS_MALLOPT -DSTUFF_STACK
- LIBRARIES = $(LDL)
-
- #For AIX 3.2 using gcc, the following would be appropriate:
- #MORECCFLAGS = -DNO_LDL -fsigned-char
- #LIBRARIES = -lbsd
-
- #For AIX 3.2 using cc, the following would be appropriate:
- #CCFLAG=
- #LDFLAG=-s
- #MORECCFLAGS = -DNO_LDL -qchars=signed
- #LIBRARIES = -lbsd
-
- #- insert -DNO_CNT in MORECCFLAGS if the FILE structure defined in <stdio.h>
- # does not contain a _cnt element
- #- insert -DSTUFF_STACK if you want surplus stacked data to be stuffed into
- # the keyboard buffer before the stack is terminated. The <sys/termios.h>
- # file should define a TIOCSTI ioctl call.
-
- MATH = rxmathfn.rxfn
-
- #For any system on which you defined -DNO_LDL above, please insert:
- #MATH =
-
-
- DATE = -DDAY=$(RXDAY) -DMONTH=$(RXMONTH) -DYEAR=$(RXYEAR)
-
- REXX = rexx rxque rxstack
- RXCFILES = rexx.c util.c calc.c rxfn.c shell.c globals.c rxmathfn.c
- CFILES = $(RXCFILES) rxque.c rxstack.c
- OFILES = rexx.o rxfn.o calc.o util.o shell.o globals.o
- HFILES = const.h globals.h functions.h
- JUNKFILES = rexx rxque rxstack *.o *.c\^ *.c% make\^ make% *.h\^ *.h% \
- rexx.ref\^ rexx.summary\^ rexx.info\^ rexx.tech\^ rxmathfn.rxfn
- FILEDEFS = -DREXXIMC=\"$(REXXIMC)\"
-
- all: $(REXX)
-
- # Installation is done by the shell, so make as "all"
- install: all
-
- rexx: $(OFILES) $(MATH)
- $(LD) $(CCFLAG) $(LDFLAG) $(DEBUG) -o rexx $(OFILES) $(LIBRARIES) \
- $(__MAIN)
-
- rxque: rxque.c
- $(CC) $(CCFLAG) $(MORECCFLAGS) -c rxque.c
- $(LD) $(CCFLAG) $(LDFLAG) -o rxque rxque.o $(LIBRARIES) $(__MAIN)
- @rm rxque.o
-
- rxstack: rxstack.c
- $(CC) $(CCFLAG) $(MORECCFLAGS) -c rxstack.c
- $(LD) $(CCFLAG) $(LDFLAG) -o rxstack rxstack.o $(LIBRARIES) $(__MAIN)
- @rm rxstack.o
-
- # compile individual object files:
-
- rex: rexx.o
-
- rxfn: rxfn.o
-
- calc: calc.o
-
- util: util.o
-
- shell: shell.o
-
- math: rxmathfn.rxfn
-
- # clobber erases the object files from the bin directory too. They have
- # already been moved here by the shell, so just do "clean"
- clobber: clean
-
- clean:
- rm -f $(JUNKFILES)
-
- lint: $(HFILES) $(CFILES)
- @echo lint $(RXCFILES)
- @(lint $(DATE) $(FILEDEFS) $(RXCFILES);\
- echo rxque.c:;\
- echo lint rxque.c >&2;\
- lint rxque.c;\
- echo rxstack.c:;\
- echo lint rxstack.c >&2;\
- lint rxstack.c) | ./lintfilter
- @echo "Messages are in /tmp/lint"
-
- rexx.o: rexx.c $(HFILES)
- $(CC) -c $(CCFLAG) $(MORECCFLAGS) $(DATE) $(FILEDEFS) rexx.c
-
- rxmathfn.rxfn: rxmathfn.c const.h functions.h
- $(CC) -c $(CCFLAG) $(MORECCFLAGS) rxmathfn.c
- ld -o rxmathfn.rxfn rxmathfn.o -lm
- @rm rxmathfn.o
-
- .c.o: $(HFILES)
- $(CC) -c $(CCFLAG) $(MORECCFLAGS) $*.c
- '|make -f - $*
-
- # Move the object files, and, if "install", the executables,
- # into the bin directory. Do not do this after "clobber", of course.
-
- if [ "x$mvfiles" != x -a x$1 != xclobber ] ; then
- echo mv $mvfiles $BINDIR
- mv $mvfiles $BINDIR 2>/dev/null;
- fi
-